﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
public partial class zoushitu_dlt_zh_dlt_ylzs : System.Web.UI.Page
{
    protected List<Model.LotteryAnnouncement> arlist = null;
    protected List<Model.LotteryAnnouncement> arlist_re = null;
    protected string[] SSQList = null;
    protected string SSQblue = null;
    protected int jinqiCount = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            jinqiCount = 30;
            bindData(30);
            YiLouZhi1(30);
        }
    }

    protected void bindData(int maxValue)
    {
        arlist = BLL.LotteryAnnouncement.getDatas(maxValue, 2);
        if (arlist != null)
        {
            for (int i = 0; i < arlist.Count; i++)
            {
                //重号
                string[] redBall = arlist[i].LotteryNo.Split('+')[0].Split(',');
                for (int m = 0; m < redBall.Length; m++)
                {
                    //计算条形图中每个数的个数红球
                    bindTiaoxing(0, int.Parse(redBall[m]));

                }
                string[] blueBall = arlist[i].LotteryNo.Split('+')[1].Split(',');
                for (int m = 0; m < blueBall.Length; m++)
                {
                    //计算条形图中每个数的个数红球
                    bindTiaoxing(1, int.Parse(blueBall[m]));

                }
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        jinqiCount = int.Parse(DropDownList1.SelectedValue);
        bindData(int.Parse(DropDownList1.SelectedValue));
        YiLouZhi1(int.Parse(DropDownList1.SelectedValue));
    }
    protected int[] TiaoxingDT = new int[49];
    /// <summary>
    /// 计算红篮球的出现个数
    /// </summary>
    /// <param name="type">0 红球 1 蓝球</param>
    /// <param name="data">对应球的号码</param>
    protected void bindTiaoxing(int type, int data)
    {
        for (int i = 0; i < 47; i++)
        {
            if (type == 0)
            {
                if (data == (i + 1))
                {
                    TiaoxingDT[i] += 1;
                }
            }
            if (type == 1)
            {
                if (data == (i + 1 - 35))
                {
                    TiaoxingDT[i] += 1;
                }
            }
        }
    }
    #region 遗漏用到的变量   
    protected List<List<List<string>>> Ylist = new List<List<List<string>>>();
    #endregion
    public void YiLouZhi1(int maxValue)
    {
        arlist = BLL.LotteryAnnouncement.getDatas(maxValue, 2);
        if (arlist == null || arlist.Count < 0) return;
        List<List<string>> winList = new List<List<string>>();//记录中奖号码和中奖期数
        for (int i = 0; i < arlist.Count; i++)
        {
            List<List<string>> yiLouList = new List<List<string>>();
            string lotteryQS = arlist[i].LotteryQS;//开奖期数
            string lotteryNo = arlist[i].LotteryNo;//开奖号码
            string num = "";
            for (int c = 1; c < 36; c++)
            {
                string[] ball = lotteryNo.Split(new char[] { '+' });
                string redballstr = ball[0];//预测号码中的红球
                string[] redballparm = redballstr.Split(new char[] { ',' });//红球
                if (c < 10)
                {
                    num = "0" + c;
                }
                else
                {
                    num = c.ToString();
                }
                string NewQS = "";
                if (i == 0)
                {
                    NewQS = arlist[0].LotteryQS;
                }
                else
                {
                    for (int m = 0; m < winList.Count; m++)
                    {
                        if ((winList[m].Contains(num)))
                        {
                            NewQS = winList[m][0];
                        }
                    }
                    if (NewQS == "")
                    {
                        NewQS = arlist[0].LotteryQS;
                    }
                }
                if (!((IList)redballparm).Contains(num))
                {
                    int MissingQS = 0;
                    List<string> list = new List<string>();
                    if (NewQS == arlist[0].LotteryQS)
                    {
                        MissingQS = Convert.ToInt32(lotteryQS) - Convert.ToInt32(NewQS) + 1;//遗漏期数
                    }
                    else
                    {
                        MissingQS = Convert.ToInt32(lotteryQS) - Convert.ToInt32(NewQS);//遗漏期数
                    }

                    list.Add(lotteryQS);
                    list.Add(c.ToString());
                    list.Add(MissingQS.ToString());
                    yiLouList.Add(list);
                }
                else
                {
                    List<string> list = new List<string>();
                    list.Add(lotteryQS);
                    list.Add(c.ToString());
                    list.Add("0");
                    yiLouList.Add(list);
                    List<string> list1 = new List<string>();
                    list1.Add(lotteryQS);
                    list1.Add(c.ToString());
                    list1.Add(num);
                    winList.Add(list1);
                }
            }
            Ylist.Add(yiLouList);
        }

    }

}